/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.butler.cezary.syncTool;

import pl.butler.cezary.syncTool.scanning.detectors.ChangeDetector;
import java.io.File;
import java.util.concurrent.TimeUnit;
import pl.butler.cezary.syncTool.scanning.DirectoryCrawler;
import pl.butler.cezary.syncTool.storage.MagazynId;
import pl.butler.cezary.syncTool.storage.SimpleFileStorage;
import pl.butler.cezary.syncTool.storage.Storage;

/**
 *
 * @author czarek
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws InterruptedException {
        final DirectoryCrawler crawler = new DirectoryCrawler();
        for(final String katalog: args)
            crawler.addDirectory(new File(katalog));
        final MagazynId magazyn = new MagazynId("I:\\Magazyn");        
        final Storage storage = new SimpleFileStorage(magazyn);        
        storage.open();
        final ChangeDetector detector = new ChangeDetector(storage);
        crawler.addEventListener(detector);
        try{
        while(true){
            crawler.goThru();
            try{
                TimeUnit.SECONDS.sleep(5);}
            catch(InterruptedException ie){
                break;
            }
        }
        }finally{
        storage.close();
        }
    }



}
